<?php

class Form
{
	private $_map = array();

	public function __construct()
	{
		foreach($_REQUEST as $k => $v) {
			$this->_map[$k] = $v;
		}
	}

	public function get($key, $defaultValue = '')
	{
		if(!isset($this->_map[$key]) || $this->_map[$key] == '') return $defaultValue;
		return $this->_map[$key];
	}

	public function set($key, $value)
	{
		$this->_map[$key] = $value;
	}

	public function isExistKey($key)
	{
		return isset($this->_map[$key]);
	}

	public function getMap()
	{
		return $this->_map;
	}

	public function setAll(&$map) {
		foreach($map as $k => $v) {
			$this->_map[$k] = $v;
		}
	}

	public function setMsg($msg, $key='_msgs')
	{
		$msg2 = AppValidateManager::getMessage($msg);
		if($msg2) $msg = $msg2;

		$arr = parent::get($key);
		if(!$arr) $arr = array();
		$arr[] = $msg;
		self::set($key, $arr);
	}

	public function setList($list) {
		$this->_map['_list'] = $list;
	}

}